<?php

//use yii\web\View;

use yii\helpers\Url;

echo $this->render('/layouts/top');

?>
<script type="text/javascript" charset="utf-8" src="/js/ajax141212.js"></script>
<script type="text/javascript" src="/js/NoLimitCategory.js"></script>
<?php

	$cname1 = empty($knowledge["cname"]) ? "" : "[".$knowledge["cname"]."]";
	$cname2 = empty($knowledge["cname2"]) ? "" : "[".$knowledge["cname2"]."]";
	$cname3 = empty($knowledge["cname3"]) ? "" : "[".$knowledge["cname3"]."]";
	$cname4 = empty($knowledge["cname4"]) ? "" : "[".$knowledge["cname4"]."]";
	$cname5 = empty($knowledge["cname5"]) ? "" : "[".$knowledge["cname5"]."]";
		
	$category = $cname1.$cname2.$cname3.$cname4.$cname5;


	$word = isset($knowledge["word"]) ? $knowledge["word"] : "";
	
			$trans = explode('|', $knowledge["trans"]);

			$trans_str = '';
			if(count($trans) > 0){
				$trans_str = implode('<br>', $trans);
				$answer .= '<br><br>'.$trans_str;
			}
			
	$right = $knowledge["right"];
?>
<div style="margin:0px auto; width:1000px;">
  <div style="">
    <div style="display:inline-block;margin:0px auto; width:1000px; margin-top:10px;">ID：<?php echo isset($knowledge["id"]) ? $knowledge["id"] : 0;?></div><!--
 --><div style="display:inline-block;margin-top:10px;">分类：<?php echo $category?></div><!--
 --><div style="margin:0px auto; width:1000px; margin-top:10px;">单词：<?php echo $word?></div>
		<div style="font-family:lucida sans unicode, arial, sans-serif;margin:0px auto; width:1000px; margin-top:10px;">
			音标：英<?php echo isset($knowledge["ipa_en"]) ? stripslashes($knowledge["ipa_en"]) : ""?>
			美<?php echo isset($knowledge["ipa_us"]) ? stripslashes($knowledge["ipa_us"]) : ""?>
		</div>
		<div style="margin:0px auto; width:1000px; margin-top:10px;">
			翻译：<br><?php echo $trans_str?>
		</div>
		<div style="margin:0px auto; width:1000px; margin-top:10px; text-align:center ">
          <input type="button" value="编辑单词" onclick="edit()"/>
			<input type="button" value="直接毕业" onclick="graduate(<?php echo $knowledge["id"]?>)"/>
          <input type="button" value="收藏单词" onclick="favorite()"/> 
        </div>
  </div>
</div>
<br>
<?php echo $this->render('/layouts/footer');?>
<script language="javascript">

var id = <?php echo isset($knowledge["id"]) ? $knowledge["id"] : 0;?>;

function edit(){
	window.location.href = "<?php echo Url::to(['/word/edit'])?>"+"?id="+id;
}

//直接毕业
function graduate(id){
	new Ajax().get({
		url : "<?php echo Url::to(['/word/async-graduate'])?>"+"?id="+id,
		resultType : 'json',
		onLoaded : function(result){
			if(result.code == 1){
				alert("成功");
				window.location.reload();
			}else{
				alert(result.info);
			}
		}
	});
}


//收藏单词
function favorite(){
	new Ajax().get({
		url : "<?php echo Url::to(['/word/favorite'])?>"+"?id="+id,
		resultType : 'json',
		onLoaded : function(result){
			console.log(result);
			if(result.code == 1){
				alert("收藏成功");
				window.location.reload();
			}else{
				alert(result.info);
			}
		}
	});
}

	
</script>
</body>
</html>